#ifndef TIMETEST_H_
#define TIMETEST_H_

#include <stdio.h>
#include <stdlib.h>
#include "Timer.h"
using namespace std;

Timer timer = Timer();

// Globally accessible Timer
int generateRandomInteger(int range)
{ 
  return rand()%range;
}

int* generateRandomData(int n)
{ 
    int *A = new int[n]; 

    for(int i=0;i<n;i++)
    { 
      A[i] = generateRandomInteger(n);
    } 
    return A;
}
double timeTest2(void (*function)(int*, int, int), int* data, int n, int y)
{
    timer.start();
    function(data,n,y);
    double duration = timer.stop();
    return duration;
}
double timeTest(void (*function)(int*, int), int* data, int n)
{
    timer.start();
    function(data, n);
    double duration = timer.stop();
    return duration;
}

void displayTimes(const char functionName[], double* times, int numberOfTests)
{
    printf ("%s \n",functionName);
    for (int i=0; i<numberOfTests; i++){
        timer.printTime(times[i]);
    }   
    double sum=0;
    for (int i=0; i<=numberOfTests; i++){
        sum = sum+times[i];
    }   
    double avg = sum/numberOfTests;
    cout<<"Average is :"<<avg<<endl;
    cout<<endl;
}


#endif /* TIMETEST_H_ */
